//
//  TrailerCell.m
//  代号：47
//
//  Created by 杨佩璋 on 15/7/3.
//  Copyright (c) 2015年 杨佩璋. All rights reserved.
//

#import "TrailerCell.h"
#import <UIImageView+WebCache.h>


@implementation TrailerCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        _picture = [[UIImageView alloc] init];
        _picture.contentMode = UIViewContentModeScaleAspectFill;
        _picture.clipsToBounds = YES;
        CGFloat h = 130 *140.0/270;
        _picture.frame = CGRectMake(10, 10, 130, h);
        
        CGFloat playW = 0.25 *130;
        UIImageView *play = [[UIImageView alloc] initWithFrame:CGRectMake(130 - playW, h - playW , playW, playW)];
        play.image = [UIImage imageNamed:@"iconfont-bofang(2)"];
        [self.picture addSubview:play];
        [play release];
        
        _titleLabel = [[UILabel alloc] init];
        CGFloat titleWidth = kScreen_width - 150 -10;
        _titleLabel.frame = CGRectMake(150, 5, titleWidth, 60);
        _titleLabel.font = [UIFont boldSystemFontOfSize:14];
        _titleLabel.textColor = [UIColor orangeColor];
        _titleLabel.textAlignment = NSTextAlignmentCenter ;
        
        _summary = [[UILabel alloc] init];
        _summary.frame = CGRectMake(150, 55, titleWidth, 20);
        _summary.textAlignment = NSTextAlignmentCenter;
        _summary.font = [UIFont systemFontOfSize:12];
        _summary.textColor = [UIColor lightGrayColor];
        
        [self.contentView addSubview:_titleLabel];
        [self.contentView addSubview:_summary];
        [self.contentView addSubview:_picture];
        
        [_picture release];
        [_titleLabel release];
        [_summary release];
        
    }
    return  self;
}



- (void)setModel:(TrailerModel *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
    [_picture sd_setImageWithURL:[NSURL URLWithString:model.coverImg]];
    _titleLabel.text = model.movieName;
    _summary.text = model.summary;
    
}



-(void)dealloc
{
    
    [_model release];
    [super dealloc];
}


@end
